package com.geek.javase.ch12.work;

/*
 *@author wangpeng
 *2025/10/23 17:48
 *@description TODO
 */
//2.喝啤酒问题，一瓶啤酒2元，两个空瓶子可以换一瓶啤酒，四个啤酒盖可以换一瓶啤酒，请问10元共可以喝多少瓶？
public class Demo2 {
    public static void main(String[] args) {
        int beer = 5;
        int empty = 0;
        int cover = 0;
        int sum = 0;
        while (beer > 0) {
            empty = empty + beer;
            cover = cover +beer;
            sum = sum + beer;
            beer = 0;
            beer = empty/2+cover/4;
            empty = empty%2;
            cover = cover%4;
        }
        System.out.println("10元可以喝"+sum+"瓶啤酒");
    }
}
